package com.ytjj.qmyx.supplychain.common.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jiawei
 * @date 2023年03月30日 14:35
 * @describe 异常订单归类枚举
 */
@Getter
public enum ExceptionOrderClassifyEnum {
    CUSTOMER_CHECK(1,0,"客户已签收（确定本人已签收）"),
    AGENT_POINT(2,0,"件在代收点（需要客户去取件）"),
    NEED_VERIFY(3,0,"需要核实在处理（丢件补发、物流停滞）"),
    REJECTED(4,0,"客户拒收了"),
    NORMAL_CARRIAGE(5,0,"物流正常运输中（派送中）"),
    URGE_EXPRESS(6,1,"需要催促物流"),
    UNCOLLECTED(7,0,"待揽收（待寄出、无物流、缺货）"),
    SENT_BACK(8,0,"件被退回了"),
    CABINET_POINT(9,0,"件在丰巢柜（或 件在蜂巢被取出）"),
    UNABLE_TO_CONTACT(10,0,"联系不上客户，地址不详电话错误");


    /**
     * 异常订单类型
     */
    private Integer classifyType;

    /**
     * 异常订单名称
     */
    private String classifyName;
    /**
     * 是否旧数据 0-有效 1-无效
     */
    private Integer oldData;

    ExceptionOrderClassifyEnum(Integer classifyType,Integer oldData, String classifyName) {
        this.classifyName = classifyName;
        this.classifyType = classifyType;
        this.oldData = oldData;
    }

    /**
     * 获得所有分类序号文本名称
     */
    public static List<String> getExceptionClassifyText() {
        ExceptionOrderClassifyEnum[] values = ExceptionOrderClassifyEnum.values();
        List<String> classifyNames = new ArrayList<>();
        for (ExceptionOrderClassifyEnum value : values) {
            if(value.getOldData() == 0){
                String name = value.getClassifyType() + "." + value.getClassifyName();
                classifyNames.add(name);
            }
        }
        return classifyNames;
    }

    /**
     * 获得所有分类，及分类序号文本名称
     */
    public static List<Map<Integer,String>> getAllExceptionClassify() {
        ExceptionOrderClassifyEnum[] values = ExceptionOrderClassifyEnum.values();
        List<Map<Integer,String>> classifyNames = new ArrayList<>();
        for (ExceptionOrderClassifyEnum value : values) {
            if(value.getOldData() == 0){
                String name = value.getClassifyType() + "." + value.getClassifyName();
                Map<Integer,String> map = new HashMap<>();
                map.put(value.getClassifyType(),name);
                classifyNames.add(map);
            }
        }
        return classifyNames;
    }

    /**
     * 根据分类类型获取带序号的分类名称
     */
    public static String getClassifyNameByType(Integer classifyType) {
        for (ExceptionOrderClassifyEnum item : ExceptionOrderClassifyEnum.values()) {
            if (item.getClassifyType().equals(classifyType)) {
                return classifyType + "." + item.getClassifyName();
            }
        }
        return "";
    }

}
